# -*- coding: utf-8 -*-
"""
Created on Thu May 19 07:36:12 2022

@author: Administrator
"""
from typing import List

class Solution:
    def largestCombination(self, candidates: List[int]) -> int:
        """
        周赛272，题目2275，求按位与后不为零的最大长度
        思路：转换问题，将每个数字都转换为二进制，然后求哪一位上为1的数字最多

        Parameters
        ----------
        candidates : List[int]
            DESCRIPTION.

        Returns
        -------
        int
            最大长度

        """
        res = 0
        cnt = [0 for _ in range(24)]   # 数字范围[1, 10**7]
        for candidate in candidates:
            for i in range(24):
                if (1<<i)&candidate != 0:
                    cnt[i] += 1
        for c in cnt:
            if c > res:
                res = c
        return res